#!/bin/bash
yesterday=$(date -d "-16 hour" -u +%Y%m%d)
cd ~/app-root/data/temp/hosts
wget -N -O hosts.txt https://raw.githubusercontent.com/racaljk/hosts/master/hosts
cat hosts.txt ~/app-root/data/github-sh/hosts/user.txt |sed -e '/127.0.0.1/'d -e '1,/Last updated/d' > hosts-bk.txt
if ! diff -q hosts-bk.txt ~/app-root/runtime/repo/hosts/hosts.txt; then
cp -f hosts-bk.txt ~/app-root/runtime/repo/hosts/hosts.txt
cat ~/app-root/runtime/repo/hosts/hosts.txt noad-bk.txt >~/app-root/runtime/repo/hosts/hosts-noad.txt
cat ~/app-root/runtime/repo/hosts/hosts.txt noad-bk.txt mwsl-bk.txt >~/app-root/runtime/repo/hosts/hosts-noad-mwsl.txt
~/app-root/data/github-sh/log/log.sh "hosts.txt hosts-noad.txt 更新"
fi
wget -N https://raw.githubusercontent.com/vokins/simpleu/master/hosts --output-document=noad.txt
cp -f noad.txt noad-bk.txt
echo >>noad-bk.txt
sed -i '1,/@SmartDirect/d' noad-bk.txt
if ! diff -q noad-bk.txt ~/app-root/runtime/repo/hosts/noad.txt; then
cp -f noad-bk.txt ~/app-root/runtime/repo/hosts/noad.txt
cat ~/app-root/runtime/repo/hosts/hosts.txt noad-bk.txt >~/app-root/runtime/repo/hosts/hosts-noad.txt
~/app-root/data/github-sh/log/log.sh "noad.txt hosts-noad.txt 更新"
fi
